<?php

namespace App\Http\Controllers\WeChat;

use App\Models\Wechat\ConfigModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ConfigController extends Controller
{
    // http get::uri
    public function index(Request $request)
    {
        if (needJson($request)) {
            $sql = ConfigModel::query();
            return $this->page($sql, $request);
        }
        $a = chatConfig();
        dd($a);
        return view('wechat.config.index');
    }

    // http get::uri/create
    public function create()
    {
        return view();
    }

    // http post::uri
    public function store(Request $request)
    {
        $key = $request->input('key');
        $value = $request->input('value');
        $data = [
            'value'=>$value
        ];
        ConfigModel::query()->where(['key'=>$key])->update($data);
        return $this->success();
    }

    // http get::uri/id
    public function show($id)
    {
        return view();
    }

    // http get::uri/id
    public function edit($id)
    {
        return view();
    }

    // http put::uri/id
    public function update(Request $request, $id)
    {
        return $this->success();
    }

    // http delete::uri/id
    public function destroy($id)
    {
        return $this->success();
    }
}
